import React from 'react';
import { Switch as AntdSwitch } from 'antd';
import css from './index.less';
import PropTypes from 'prop-types';

export default class Switch extends React.Component {

  static propTypes = {
    label: PropTypes.string,
    checked: PropTypes.bool,
    size: PropTypes.oneOf(['default', 'small']),
    checkedChildren: PropTypes.string,
    unCheckedChildren: PropTypes.string,
    onChange: PropTypes.func,
  };

  static defaultProps = {
    label: '二级标题',
    checked: false,
    size: 'default',
    checkedChildren: '',
    unCheckedChildren: '',
    onChange: () => {},
  };

  render() {
    let { label, checked, onChange, size, checkedChildren, unCheckedChildren } = this.props;
    const props = {
      className: css.row,
    };
    const switchProps = {
      onChange,
      checked,
      size,
      checkedChildren,
      unCheckedChildren,
    };
    return (
      <div {...props}>
        <div className={css.label}>
          &bull; {label}
        </div>
        <AntdSwitch {...switchProps} />
      </div>
    );
  }
}
